package com.company.jvm;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class OOMObject {
    public byte[] placeholder=new byte[64*1024];

    public static void fillHeap(int number)throws Exception{
        List<OOMObject> list=new ArrayList<>();
        for(int i=0;i<number;i++){
            Thread.sleep(50);
            list.add(new OOMObject());
        }

        System.gc();

    }

    public static void main(String[] args) throws Exception{
        fillHeap(1000);

        while (true){
            Thread.sleep(100);
        }
    }
}
